package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.security.ScanModuleDTO;
import com.enation.app.javashop.model.security.ScanResult;
import com.enation.app.javashop.service.trade.order.TradeManager;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 交易相关API
 *
 * @author zs
 * @version v2.0
 * @since v7.0.0
 */
@Api(description = "交易相关API")
@RestController
@RequestMapping("/client/trade")
@Validated
@ApiIgnore
public class TradeClientController {

    @Autowired
    @Qualifier("tradeManagerImpl")
    private TradeManager tradeManager;

    @PostMapping("/scan-module")
    public ScanResult scanModule(@RequestBody ScanModuleDTO scanModuleDTO) {
        return tradeManager.scanModule(scanModuleDTO);
    }

    @GetMapping("/resign")
    public void reSign() {
        tradeManager.reSign();
    }

    @GetMapping("/repair/{trade_id}")
    public void repair(@PathVariable("trade_id") Long tradeId) {
        tradeManager.repair(tradeId);
    }
}
